{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7a2ced9c",
   "metadata": {},
   "source": [
    "# 本周学习内容"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "434198ca",
   "metadata": {},
   "source": [
    "## 1.Head First Python P4\n",
    ">一定要按照以下规格书写代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "95dbb4a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13\n",
      "现在瞬时时间 秒的最后一位数字为奇数\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 本项目用到了时间模块\n",
    "# print(datetime.datetime.today().microsecond)\n",
    "\n",
    "# odds 是一个变量，后面可以直接使用\n",
    "odds = [  1, 3,  5,  7,  9, 11,13,15,17,19,\n",
    "             21,23,25,27,29,31,33,35,37,39,\n",
    "             41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "# right_this_minute 是一个变量，是随着当前时间分钟数不断变化的一个值\n",
    "right_this_minute = datetime.datetime.today().second\n",
    "\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(right_this_minute)\n",
    "    print(\"现在瞬时时间 秒的最后一位数字为奇数\")\n",
    "else:\n",
    "    print(datetime.datetime.today().second)\n",
    "    print(\"现在瞬时时间 秒的最后一位数字为偶数\")\n",
    "\n",
    "# print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "4bbb5828",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "9efe39b4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "今天没有python课，哈哈哈哈也很开心~\n"
     ]
    }
   ],
   "source": [
    "# tm_wday： 0-6   其中0 是星期一\n",
    "今天 = time.localtime().tm_wday\n",
    "\n",
    "if 今天 == 1:\n",
    "    print(\"今天有python课，哈哈哈哈哈哈哈哈哈，太开心了！时间为：下午2：30-4：50\")\n",
    "else:\n",
    "    print(\"今天没有python课，哈哈哈哈也很开心~\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "aebc5628",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "现在不是在上课\n"
     ]
    }
   ],
   "source": [
    " 现在的时间 = time.localtime().tm_hour\n",
    "\n",
    "if 现在的时间 == 11:\n",
    "    print(\"现在是周一早上的Python课\")\n",
    "else:\n",
    "    print(\"现在不是在上课\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8d52d758",
   "metadata": {},
   "source": [
    "# 课后作业\n",
    "判断当前是一周中的星期几，如果是星期二，看下现在几点了，是python课ing么？然后打印Python课表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c845c061",
   "metadata": {},
   "outputs": [],
   "source": [
    "#wkday = 0,1,2,3,4,5,6 分别指周一到周日\n",
    "import time\n",
    "wday = time.localtime().tm_wday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "63ade833",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "time_hour = time.localtime().tm_hour"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "86f68dc4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "周一早上有Python课\n"
     ]
    }
   ],
   "source": [
    "if wday == 0:\n",
    "    print(\"周一早上有Python课\")\n",
    "elif time == 12 and time_min > 50:\n",
    "    print(\"正在上Python课\")\n",
    "elif time_hour == 13:\n",
    "    print(\"正在上课，大概第二节了\")\n",
    "elif time_hour == 14:\n",
    "    print(\"正在上课，妈呀，还在上，才两点多\")\n",
    "elif time_hour == 15:\n",
    "    print(\"坚持一下，快下课啦\")\n",
    "elif time_hour == 16 and time_min<50:\n",
    "    print(\"最后一节课了，快下课啦\")\n",
    "else:\n",
    "    (\"今天有Python课，上课时间为下午12.50-16.50\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d8a4b6d6",
   "metadata": {},
   "source": [
    "## 2.1模块（标准库）\n",
    "·标准库是Python开发团队为满足Python用户日常需求而写好的一些模块，可以直接使用（import）模块名称     \n",
    ">1. sys模块\n",
    ">2. os模块\n",
    ">3. datetime模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ccc58737",
   "metadata": {},
   "source": [
    "##  2.2 模块--开源模块（pypi.org）\n",
    ">1.因为代码开源\n",
    ">2.集合全领域（全人类）的需求\n",
    ">3.按照国际标准开放的模块库"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa5e0772",
   "metadata": {},
   "source": [
    "## 2.3自定义模块\n",
    ">1.不愿意开源的有一定知识产权的（开放API租用形式开放）\n",
    "2.自己用的，写的也不怎么好，开源出去丢人的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "bb3857db",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "5a06b9f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3.9.12 (main, Jun  1 2022, 06:34:44) \\n[Clang 12.0.0 ]'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "b4d9a682",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "3d57bb4e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/Users/henjunhao/Desktop/test1/Python2022-2023-01'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "8fc7fb7a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2e8c880a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 10, 17)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "d96d970e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=10, tm_mday=17, tm_hour=17, tm_min=1, tm_sec=51, tm_wday=0, tm_yday=290, tm_isdst=0)"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "664fbd04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Mon Oct 17 17:05:03 2022'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.asctime(time.localtime())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "81bd0964",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
